#include <iostream>
#include <string>
using namespace std;

const int kMaxN = 210;
const int kInf = 1e9;

int f[2][kMaxN][kMaxN];

void Init(int pos, int n, int k) {
  for (int i = 0; i <= pos; i++) {
    for (int j = 0; j <= min(k, pos); j++) {
      f[pos & 1][i][j] = -kInf;
    }
  }
}

void Renew(int& a, int b) {
  a = max(a, b);
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, k;
  string s, t;

  cin >> n >> k;
  cin >> s >> t;
  Init(0, n, k);
  f[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    Init(i + 1, n, k);
    for (int j = 0; j <= i; j++) {
      for (int l = 0; l <= min(k, i); l++) {
        if (f[i & 1][j][l] != -kInf) {
          Renew(f[(i + 1) & 1][j + 1][l + (s[i] != t[0])], f[i & 1][j][l] + (t[0] == t[1]) * j);
          Renew(f[(i + 1) & 1][j + (t[0] == t[1])][l + (s[i] != t[1])], f[i & 1][j][l] + j);
          Renew(f[(i + 1) & 1][j][l], f[i & 1][j][l]);
        }
      }
    }
  }

  int ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      ans = max(f[n & 1][i][j], ans);
    }
  }
  cout << ans << "\n";
  return 0;
}